# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=fluxion
pkgver=1593.2a338a2
pkgrel=1
epoch=5
pkgdesc='A security auditing and social-engineering research tool.'
arch=('any')
groups=('blackarch' 'blackarch-social' 'blackarch-wireless')
url='https://github.com/FluxionNetwork/fluxion'
license=('GPL3')
source=("git+https://github.com/FluxionNetwork/$pkgname.git")
depends=('aircrack-ng' 'bash>=4.2' 'coreutils' 'awk' 'iw' 'unzip' 'curl' 'bc'
         'xterm' 'cowpatty' 'dhcp' 'dsniff' 'p7zip' 'hostapd' 'lighttpd'
         'macchanger' 'mdk3' 'mdk4' 'nmap' 'php-cgi' 'xorg-xdpyinfo')
makedepends=('binutils' 'coreutils' 'git')
sha512sums=('SKIP')

prepare() {
  install -dm 755 "$srcdir/$pkgname"
}

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 -t "$pkgdir/usr/share/man/man1/" "docs/man/$pkgname.1"
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf *.md .git* *.yml .project .editorconfig

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bash $pkgname.sh "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

